#include "qmyvideowidget.h"

QmyVideoWidget::QmyVideoWidget(QWidget *parent) : QVideoWidget(parent)
{

}

void QmyVideoWidget::setMediaPlayer(QMediaPlayer *player)
{
    thePlayer=player;
}

//键盘事件函数
void QmyVideoWidget::keyPressEvent(QKeyEvent *event)
{
    if((event->key()==Qt::Key_Escape) && (isFullScreen()))
    {
        setFullScreen(false);
        event->accept();
        QVideoWidget::keyPressEvent(event);
    }
}

//鼠标事件函数
void QmyVideoWidget::mousePressEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        if(thePlayer->state()==QMediaPlayer::PlayingState) thePlayer->pause();
        else thePlayer->play();
    }

    QVideoWidget::mousePressEvent(event);
}
